package com.frejoys.dao.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.frejoys.dao.entity.StoreStatisticsMonth;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

public interface StoreStatisticsMonthMapper extends BaseMapper<StoreStatisticsMonth> {

    // 添加信息
    @Insert("insert into j_store_statistics_month (store_id,price,rebate_money,promotion_money,commission_money,money,bank_cash_charges_money,y,ym,create_time) values (#{storeId}, #{price}, #{rebateMoney}, #{promotionMoney}, #{commissionMoney}, #{money}, #{bankCashChargesMoney}, #{y}, #{ym}, #{createTime})")
    boolean addInfo(@Param("storeId") Integer storeId, @Param("price") BigDecimal price, @Param("rebateMoney") BigDecimal rebateMoney, @Param("promotionMoney") BigDecimal promotionMoney, @Param("commissionMoney") BigDecimal commissionMoney, @Param("money") BigDecimal money, @Param("bankCashChargesMoney") BigDecimal bankCashChargesMoney, @Param("y") Integer y, @Param("ym") Integer ym, @Param("createTime") Integer createTime);

    // 获取信息
    @Select("select id from j_store_statistics_month where store_id=#{storeId} and ym=#{ym} limit 1")
    StoreStatisticsMonth getIdInfo(@Param("storeId") Integer storeId, @Param("ym") Integer ym);

    // 递增相关数据
    @Update("update j_store_statistics_month set price=price+#{price},rebate_money=rebate_money+#{rebateMoney},promotion_money=promotion_money+#{promotionMoney},commission_money=commission_money+#{commissionMoney},money=money+#{money},bank_cash_charges_money=bank_cash_charges_money+#{bankCashChargesMoney} where id=#{id}")
    boolean upInfo(@Param("id") Integer id, @Param("price") BigDecimal price, @Param("rebateMoney") BigDecimal rebateMoney, @Param("promotionMoney") BigDecimal promotionMoney, @Param("commissionMoney") BigDecimal commissionMoney, @Param("money") BigDecimal money, @Param("bankCashChargesMoney") BigDecimal bankCashChargesMoney);

}
